package org.example.utils;

import org.example.Main;

import java.io.File;
import java.util.concurrent.Semaphore;

public class MyMethod {
    private Semaphore semaphore = new Semaphore(10);

    private int count = 0;

    /**
     * 限制同时io的条数默认一次同时10个
     *
     * @param file
     * @throws InterruptedException
     */
    public void threadCopy(File file) {
        try {
            semaphore.acquire();
            // 模拟方法执行时间
           Main.copy(file);
        } catch (Exception e) {
            System.out.println("异常文件：" + e.getMessage());
        } finally {
            semaphore.release();
        }
    }
}